package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "tnb_rel_service_preference")
@JsonApiResource(type = "relServicePreference")
public class RelServicePreference extends BaseEntity {
	private CustomerServiceItem serviceItem;
	private CustomerPreference preference;

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "service_id", foreignKey = @ForeignKey(name = "null"))
	public CustomerServiceItem getServiceItem() {
		return serviceItem;
	}

	public void setServiceItem(CustomerServiceItem serviceItem) {
		this.serviceItem = serviceItem;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "preference_id", foreignKey = @ForeignKey(name = "null"))
	public CustomerPreference getPreference() {
		return preference;
	}

	public void setPreference(CustomerPreference preference) {
		this.preference = preference;
	}
}
